<?php

function printUsage() {
    echo "\nUsage:      php GetMyLogs.php /path/to/svn.log svnuser\n";
    echo "\nInfo:       You can obtain an input file by using \"svn log -v > svn.log\" for example.\n";
    echo "\nExample 1:  php GetMyLogs.php svn.log svnuser\n";
    echo "\nExample 2:  php GetMyLogs.php svn.log svnuser > user.logs\n\n";
    exit;
}

if(isset($argv[1]) && ($argv[1] == "-h" || $argv[1] == "--help")) {
    printUsage();
}
if(!isset($argv[1])) {
    printUsage();
} else {
    $inputFile = $argv[1];
}
if(!isset($argv[2])) {
    printUsage();
} else {
    $user = $argv[2];
}

$logFile = file($inputFile);
$logFileText = implode("",$logFile);
$pattern = "/r\d{1,4} \| $user \| \d\d\d\d\-\d\d\-\d\d(.*)[-]{72}/Us";
$matches = array();
$success = preg_match_all($pattern,$logFileText,$matches);
foreach($matches[0] as $match) {
    echo $match . "\n";
}
echo "\n";
